package com.example.boot.repository

import com.example.boot.domain.SettingsV2
import org.hibernate.type.BigIntegerType
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional
import java.math.BigInteger
import javax.persistence.EntityManager
import javax.persistence.PersistenceContext

@Repository
class SettingsRepositoryV3 {

    @PersistenceContext
    private lateinit var entityManager: EntityManager

    @Transactional
    fun insertSettings(settingsV2: SettingsV2) {
        entityManager.createNativeQuery("insert into t_settings_v2 (name, value) values (?, ?)")
            .setParameter(1, settingsV2.name)
            .setParameter(2, settingsV2.value)
            .executeUpdate()
    }

    @Transactional
    fun insertSettings2(settingsV2: SettingsV2) {
        entityManager.persist(settingsV2)
    }
}